Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libbpf: Fix uprobe offset calculation #8647

Open
wants to merge 1 commit into
base: bpf-next_base
Choose a base branch
from

Conversation

chenhengqi
Copy link
Contributor

As reported on libbpf-rs issue(0), the current implementation may resolve symbol to a wrong offset and thus missing uprobe events. Calculate the symbol offset from program header instead. This is almost the same as the original implementation in commit 433966e ("libbpf: Support function name-based attach uprobes") but with phdr.p_flags & PF_X check dropped. This is because we also use this to calculate offset for non-func symbols like in uprobe multi selftest. See the kernel doc (1) and spec (2) for references.

Fixes: fe92833 ("libbpf: Fix uprobe symbol file offset calculation logic")
Fixes: 3774705 ("libbpf: Add elf symbol iterator")
Reported-by: Guilherme Pascoal [email protected]

As reported on libbpf-rs issue([0]), the current implementation
may resolve symbol to a wrong offset and thus missing uprobe
events. Calculate the symbol offset from program header instead.
This is almost the same as the original implementation in commit
433966e ("libbpf: Support function name-based attach uprobes")
but with `phdr.p_flags & PF_X` check dropped. This is because we
also use this to calculate offset for non-func symbols like in
uprobe multi selftest. See the kernel doc ([1]) and spec ([2]) for
references.

  [0]: libbpf/libbpf-rs#1110
  [1]: https://www.kernel.org/doc/html/latest/trace/uprobetracer.html
  [2]: https://refspecs.linuxfoundation.org/elf/

Fixes: fe92833 ("libbpf: Fix uprobe symbol file offset calculation logic")
Fixes: 3774705 ("libbpf: Add elf symbol iterator")
Reported-by: Guilherme Pascoal <[email protected]>
Signed-off-by: Hengqi Chen <[email protected]>
@kernel-patches-daemon-bpf kernel-patches-daemon-bpf bot force-pushed the bpf-next_base branch 3 times, most recently from 44c3a1d to 720c696 Compare March 12, 2025 23:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant